<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Slide extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		$this->load->view('plan');
	}
    
	
	public function lists()
	{
		$page=$this->input->get('page');

		//列表的第N页，默认第一页
		$pid=intval($page)>1?intval($page):1;

		
		/**
		* 校验pid为数字
		*/
		if(!preg_match('/^[1-9]\d*$/',$pid)){
			
			$OUTPUT['code']=3;
			$OUTPUT['status']='Invalid Parameter';
			
			show_404('页面');
			
			exit;
		}
		
		$this->load->model('slide_model','slide');
		

		$OUTPUT=$this->slide->queryListData($pid);

		
		if(is_null($OUTPUT)){
			show_404('页面');
			exit;
		}
		
		

		$this->load->view('slide_list',$OUTPUT);
	}
    
	
	public function search()
	{
		$page=$this->input->get('page');

		//列表的第N页，默认第一页
		$pid=intval($page)>1?intval($page):1;

		
		/**
		* 校验pid为数字
		*/
		if(!preg_match('/^[1-9]\d*$/',$pid)){
			
			$OUTPUT['code']=3;
			$OUTPUT['status']='Invalid Parameter';
			
			show_404('页面');
			
			exit;
		}
		
		$this->load->model('slide_model','slide');
		

		$OUTPUT=$this->slide->queryListData($pid);

		
		if(is_null($OUTPUT)){
			show_404('页面');
			exit;
		}
		
		
		$OUTPUT['categoryList']=array(
			null,'Industry News','Events','Product Updates','Industry Knowledge','Trends & Insights'
		);


		$this->load->view('slide_list',$OUTPUT);
	}
    
	
	
	
	public function hot()
	{
		
		$OUTPUT=array();
		
		$this->load->model('slide_model','slide');
		

		$OUTPUT['data']=$this->slide->queryListBy('view_count');

		
		if(is_null($OUTPUT['data'])){
			show_404('页面');
			exit;
		}
		

		$this->load->view('slide_hot',$OUTPUT);
	}
	
	public function latest()
	{
		$OUTPUT=array();
		
		$this->load->model('slide_model','slide');
		

		$OUTPUT['data']=$this->slide->queryListBy('publish_date');

		
		if(is_null($OUTPUT['data'])){
			show_404('页面');
			exit;
		}
		

		$this->load->view('slide_latest',$OUTPUT);
	}

	
	
	public function slide_new()
	{
		$this->load->view('slide_upload');
	}
	
	
	public function slide_preview($pid)
	{
        $this->load->view('slide_item_preview');
    }
	
	
    public function slide_item($pid)
	{
		
		/**
		* 校验pid为数字
		*/
		if(!preg_match('/^[1-9]\d*$/',$pid)){
			
			$OUTPUT['code']=3;
			$OUTPUT['status']='Invalid Parameter';
			
			show_404('页面');
			
			exit;
		}
		
		$this->load->model('slide_model','slide');
		

		$OUTPUT=$this->slide->queryItemData($pid);

		
		if(is_null($OUTPUT)){
			show_404('页面');
			exit;
		}
		
        $this->load->view('slide_item',$OUTPUT);
    }
	
	
	
	public function slide_hash()
	{
		$hash=$this->input->get('hash');
		
		if(empty($hash)){
			//show_404('页面');
			//exit;
		}
	}
	
	
	
	
}
